import datetime
import multiprocessing
from util import *
import copy
from CloudSystem import run_once



def generate_default_args():
    args=Args()
    args.deploy_schedule_strategy = "ours"
    args.bare_metal_node_num=10
    args.ms_number_for_each_node=108
    args.random_seed_for_info=10
    args.deadline_factor=0.0
    args.min_reliability=0.95
    args.max_reliability=0.9999
    args.min_lambda_transient_ms=0.0010
    args.max_lambda_transient_ms=0.0018
    args.min_ms_kind_cost=0.06
    args.max_ms_kind_cost=0.9
    args.ave_bandwidth=20*1024*1024/1000  #20MBps
    args.until_time=0
    args.print_level=0
    args.request_num=500
    args.trace_id=0
    args.time_expand=1
    
    return args


def run_once_this(method, time_expand):
    print(f"start once {method}, {time_expand}")
    args=generate_default_args()
    
    args.deploy_schedule_strategy=method
    args.time_expand=time_expand
      
    args_copy=copy.deepcopy(args)
    run_once(args_copy)
    print(f"End once {method}, {time_expand}")
    
    



task_args_list=[]

for time_expand in [0.5+i/10 for i in range(11)]:
    for method in ["ours", "RR"]:#
        task_args_list.append((method, time_expand))
        
                

with multiprocessing.Pool(processes=10) as pool:
        # 使用 starmap 方法将任务分配给进程池中的进程执行
        pool.starmap(run_once_this, task_args_list)


    
print("End all sub threadings")
